package com.maoatao.easycodegen.toolkit;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.maoatao.easycodegen.framework.model.Pagination;

import java.util.function.Function;

/**
 * PageUtil
 *
 * @author MaoAtao
 * @date 2025-10-04
 */
public class PageUtil {
    public static <T, R> Pagination<R> convert(Page<T> page, Function<T, R> converter) {
        return new Pagination<>(page.getRecords().stream().map(converter).toList(), page.getTotal(), page.getSize(), page.getCurrent());
    }
}
